package com.shangxia.spr.business.attribute.handler;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.shangxia.spr.config.SystemContext;
import com.shangxia.spr.enums.AttributeCategoryEnum;
import com.shangxia.spr.frame.AttributeHandler;
import com.shangxia.spr.mapper.dao.Attribute;
import com.shangxia.spr.po.vo.BaseAttributeVO;
import com.shangxia.spr.po.vo.PanelAttributeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author zhouya38158
 * @date 2021/11/18 15:26
 * @apiNote 原始属性计算
 */
@Component("attributeBaseHandler")
public class AttributeBaseHandler extends AbstractAttributeHandler implements AttributeHandler {
    @Autowired
    private AttributeQualificationHandler nextHandler;

    @Override
    public void calculate(PanelAttributeVO panelAttributeVO) {
        BaseAttributeVO baseAttributeVO = panelAttributeVO.getBaseAttributeVO();
        QueryWrapper<Attribute> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("attributeType", AttributeCategoryEnum.BASE_ATTRIBUTE);
        queryWrapper.eq("npcCode", SystemContext.NPC_CODE);
        List<Attribute> list = attributeService.list(queryWrapper);
//        list.stream().peek(attribute -> baseAttributeVO.setField(attribute, attribute.getBaseAttributeEnum().name())).close();
        nextHandler.calculate(panelAttributeVO);
    }
}
